-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/http language support #5778
base: main
Are you sure you want to change the base?
Conversation
…crosoft/kiota into feature/http-language-support
@@ -4,3 +4,11 @@ public static class Constants | |||
public const string DefaultOpenApiLabel = "default"; | |||
public const string TempDirectoryName = "kiota"; | |||
} | |||
|
|||
public enum Authentication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to a dedicated file, give it a more explicit name
|
||
if (config.Language == GenerationLanguage.HTTP && openApiDocument is not null) | ||
{ | ||
await settingsFileManagementService.WriteSettingsFileAsync(config.OutputPath, openApiDocument, cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add logs to track the step like other steps before
} | ||
} | ||
|
||
private void AddHttpSecurity(CodeClass codeClass, OpenApiSecurityScheme securityScheme) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opportunity to refactor to more concise code with the switch since all that's changing is the name
|
||
public AuthenticationSettings() | ||
{ | ||
HostAddress = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialization can be done directly on the properties.
use string.Empty instead
private static SettingsFile GenerateSettingsFile(OpenApiDocument openApiDocument) | ||
{ | ||
var settings = new SettingsFile(); | ||
settings.EnvironmentVariables.Development.HostAddress = openApiDocument.Servers[0].Url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should check a server is present first
.Where(static property => property.IsOfKind(CodePropertyKind.QueryParameter)) | ||
.ToList(); | ||
|
||
queryParameters.AddRange(queryParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a select many instead, and combine the linq statements to reduce allocations
var pathParameters = requestBuilderClass | ||
.GetChildElements(true) | ||
.OfType<CodeProperty>() | ||
.Where(property => property.IsOfKind(CodePropertyKind.PathParameters) && !property.Name.Equals("pathParameters", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then use a constant reference instead please
{ | ||
// Retrieve the base URL property from the request builder class | ||
return requestBuilderClass.Properties | ||
.FirstOrDefault(property => property.Name.Equals("BaseUrl", StringComparison.OrdinalIgnoreCase))?.DefaultValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a constant
if (processedClasses == null) | ||
{ | ||
processedClasses = new HashSet<CodeClass>(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (processedClasses == null) | |
{ | |
processedClasses = new HashSet<CodeClass>(); | |
} | |
processedClasses ??= new HashSet<CodeClass>(); |
namespace Kiota.Builder.Writers.Http; | ||
public class CodePropertyWriter(HttpConventionService conventionService) : BaseElementWriter<CodeProperty, HttpConventionService>(conventionService) | ||
{ | ||
public override void WriteCodeElement(CodeProperty codeElement, LanguageWriter writer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we at least make a generic NO-OP writer, that we could reuse, to avoid the duplication?
Add support for HTTP snippet generation as a language option.